<html> 
 <head> 
   <script type="text/javascript"> 
     function onSelection(text) { 
       document.getElementById("output").innerHTML = text; 
     } 
     chrome.extension.getBackgroundPage().getSelection(onSelection); 
     alert("Selected Text is : " + 
chrome.extension.getBackgroundPage().getSelection()); 
   </script> 
 </head> 
 <body> 
   <div id="output">This should be replaced with the selected text</div> 
 </body> 
</html>
